<template>
	<view>
		<view class="c-box" v-for="item in list" :key="item.id" @click="toDetail(item.id)">
			<h3>{{item.title}}</h3>
			<view class="fl mt32">
				<view >
					<u-image :src="$http+item.cover" height="180rpx" width="220rpx" radius="10"></u-image>
				</view>
				<view class="ml32">
					<view  >
						<u-parse  :content="item.content" :domain="$http"></u-parse>
					</view>
					<view class="fl jsp mt16">
						<view class="fl alc">
							<u-icon name="chat"></u-icon>
							<text>{{item.commentNum}}</text>
						</view>
						<view class="fl alc">
							<u-icon name="clock"></u-icon>
							<text>{{item.publishDate}}</text>
						</view>
					</view>
				</view>
			</view>
			
		</view>
	</view>
</template>

<script setup>
	import {onLoad} from '@dcloudio/uni-app'
import { ref } from 'vue';
import { getSearchAPI } from '../../../api';
const title =ref()
	const list =ref()
	const getList =async()=>{
		const res= await getSearchAPI(title.value)
		list.value =res.rows
		list.value.map(item=>{
			item.content = item.content.slice(0,50)
		})
	}
	const toDetail =(id)=>{
		uni.navigateTo({
			url:'/subpages/indexDetail/indexDetail?id='+id
		})
	}
	onLoad((options)=>{
		title.value =options.title
		getList()
	})
</script>

<style>

</style>
